﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace _1._4线程等待
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("stating……");
            Thread td = new Thread(PrintNumbersWithDelay);
            td.Start();
            td.Join();//等待线程td完成后，继续主线程
            Console.WriteLine("Thread completed!");
            Console.ReadLine();
        }

        static void PrintNumbersWithDelay() 
        {
            Console.WriteLine("stating……");
            for (int i = 0; i < 10; i++)
            {
                Thread.Sleep(TimeSpan.FromSeconds(2));
                Console.WriteLine(i);
            }
        }
    }
}
